#include "hspext.as"
sdim ar4my_macro,70,70
#include "ar4macros.hsp"
#include "tack_replace.hsp"
#include "FILE_WM.hsp"
replace_init
//	inputp
sdim s,10000

//	pmesboxp
sdim t,4000
sdim tt,4000

//	o͗pmesboxp
sdim u,60000
//	memopmesboxp
sdim for_memo,60000
	s=""
	t=""
	tt=""
	u=""
	for_memo=""
	cls 0
	screen 0,600,600
	objsize 65,25
	pos 0,0
	button "input clear",*clear_str
	pos 70,0
	button "y[Xg",*paste_1
	pos 140,0
	button "UNDO",*undo_1
	pos 210,0
	button "s",*chg_str
	pos 280,0
	button "",*do_notepad
	pos 0,25
	mes ""
	pos 0,45
//	u̓GA
	mesbox s,400,120,1
	i_input=stat
	
	pos 0,170
	mes "`"
	pos 0,190
	button "input clear",*clear_A
	pos 80,190
	button "y[Xg",*paste_A
	pos 160,190
	button "UNDO",*undo_A
	
	pos 0,215
//	A̓GA
	input t,400,20
	ii_input=stat
	
	pos 0,235
	mes "a"
	pos 0,255
	button "input clear",*clear_B
	pos 80,255
	button "y[Xg",*paste_B
	pos 160,255
	button "UNDO",*undo_B
	pos 0,280
	
//	B̓GA
	mesbox tt,300,100,1
	i_mesbox=stat

	pos 300,235
	mes ""
	pos 300,255
	button "input clear",*clear_r
	pos 380,255
	button "Rs[",*r_copy
	pos 460,255
	button "UNDO",*undo_r
	
	pos 300,280
//	o̓GA
	mesbox u,300,100,1
	result_mesbox=stat
	pos 0,380
	mes "memopmesbox"
//	memoGA
	mesbox for_memo,600,200
	stop
//	notepadN
*do_notepad
	exec "notepad"
	stop
//	uGANA
*clear_str
	clear@obj_WM i_input,s
	stop
//	AGANA
*clear_A
	clear@obj_WM ii_input,t
	stop
//	BGANA
*clear_B
	clear@obj_WM i_mesbox,tt
	stop
//	o̓GANA
*clear_r
	clear@obj_WM result_mesbox,u
	stop
//	uGApaste
*paste_1
	paste@obj_WM i_input
	stop
//	AGApaste
*paste_A
	paste@obj_WM ii_input
	stop
//	BGApaste
*paste_B
	paste@obj_WM i_mesbox
	stop
//	o̓GARs[
*r_copy
	copy_all@obj_WM result_mesbox,u
	stop
//	uGAundo
*undo_1
	logmes "undo"
	undo@obj_WM i_input
	stop
//	AGAundo
*undo_A
	logmes "undo"
	undo@obj_WM ii_input
	stop
//	BGAundo
*undo_B
	undo@obj_WM i_mesbox
	stop
//	o̓GAundo
*undo_r
	undo@obj_WM result_mesbox
	stop
	
//	us
*chg_str
//	A̕BԂl͕
	num=split_A()
//	uABԂl͒ǔ
	my_hoge=replace_A(num)
//	m[gpbh̎̕擾p
	sdim tmp_for_note,256
//	o͗pGAɏo͂邽߂̕ϐ
	sdim my_piyo,2000
	my_piyo=""
//	tt͓B̓GAŎgĂϐ
	notesel tt
	if tt=""{
//	tt͓B̓GAȂ̂Œȗɏo
		objprm result_mesbox,my_hoge
		stop
	}
//	tt̍sJԂ
	repeat notemax
//	m[gpbhs擾
		noteget tmp_for_note,cnt
//	擾̂łȂ

		if tmp_for_note!=""{
//	B̕BԂl͕
			num_B=split_B(tmp_for_note)
//	uBsāAo͂ɉZ
//	my_hoge͒uA̎s̕
//	uȂû
			my_piyo+=replace_B(my_hoge,num_B,num)+"\n"
		}
		loop
//	o͂mesboxɔf
	objprm result_mesbox,my_piyo
//	o͗pmesboxŎgĂϐ𔽉f
	u=my_piyo
	stop
	
//	uA
#defcfunc replace_A int p
//	s͒u
	hoge=s
//	͕̌B̐JԂ
	repeat p
//	hoge͒ułԂl
//	ar4macroɂ%x̕񂪓Ă
//	split_byzɂ͒u񂪕ēĂ
//	̈AԂlŒus
	hoge=tack_replace(hoge,ar4my_macro(cnt+1),split_by(cnt))
	loop
//	u̕ԂlԂ
	return hoge
	
//	uB
//	hogehogeFu
//	ppFu
//	indexFuŏ̔Ԗ
//	r܂ŒuAŒuĂ̂
#defcfunc replace_B var hogehoge,int pp,int index
//	o͗pϐ
	sdim buzz,256
	buzz=hogehoge
//	uJԂ
	repeat pp
;	logmes "pp:"+str(pp)
;	logmes "index:"+str(index)
//	buzz͒ułԂl
//	ar4macroɂ%x̕񂪓Ă
//	split_by_Bzɂ͒u񂪕ēĂ
//	̈AԂlŒus
	buzz=tack_replace(buzz,ar4my_macro(cnt+index+1),split_by_B(cnt))
	loop
//	u̕ԂlԂ
	return buzz
	
//	A̕
#defcfunc split_A
//	i[pz
	sdim split_by,70,70
//	;ŕ
	split t,";",split_by
//	
	l=stat
//	Ȁꍇ
	if t=="":l=0
//	̍Ō̒liȂj
	l_tmp=l-1
//	1̂Ń}CiXȂ0
	if l_tmp<0:l_tmp=0
//	Ōオ̏ꍇi0Ȃ΁j
	if (split_by.l_tmp=="")&&(l>0):l--
;	logmes str(l)
;	repeat l
;		logmes split_by.cnt
;	loop
//	Ԃ
	return l
	
//	B̕
#defcfunc split_B var pv
//	i[pz
	sdim split_by_B,70,70
//	;ŕ
	split pv,";",split_by_B
//	
	ll=stat
//	B̏ꍇ
	if pv=="":ll=0
//	̍Ō̒liȂj
	ll_tmp=ll-1
//	1̂Ń}CiXȂ0
	if ll_tmp<0:ll_tmp=0
//	Ōオ̏ꍇi0Ȃ΁j
	if (split_by_B.ll_tmp=="")&&(ll>0):ll--
;	logmes str(ll)
;	repeat ll
;		logmes split_by_B.cnt
;	loop
//	Ԃ
	return ll